package org.tcs.com.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.tcs.com.dao.IncidentDAO;
import org.tcs.com.model.Incident;

@Service
public class IncidentService {
	
	private IncidentDAO incidentDAO;

	/**
	 * @param incidentDAO
	 */
	@Autowired
	public IncidentService(IncidentDAO incidentDAO) {
		this.incidentDAO = incidentDAO;
	}

	@Transactional
	public void createIncident(Incident incident){
		incidentDAO.create(incident);
	}
	
	private void sendEmail(Incident incident) {
		// TODO Auto-generated method stub
		
	}

	@Transactional
	public void updateIncident(Incident incident){
		incidentDAO.update(incident);
	}
	
	public List<Incident> getIncidents(){
		return incidentDAO.fetchAll();
	}
	
	public Incident getIncident(long incidentId){
		return incidentDAO.fetch(incidentId);
	}
	
}
